<template>
	<view class="user-wrap">
		<image class="bg-user" src="@/static/bg_user.png" mode=""></image>
		<view class="user-content">
			<view class="header">
				<view class="set" @click="navigatorTo('set')">
					<u-icon name="setting-fill" size="48rpx" color="#666"></u-icon>
				</view>
				<view class="info-wrap">
					<image class="avatar" src="@/static/icon_user_default.png" mode=""></image>
					<view class="info">
						<view class="name">{{userInfo.crtUserName}}</view>
						<view class="company">
							<image class="icon" src="@/static/icon_vip_gray.png" mode=""></image>
							</u-icon>
							<view>{{userInfo.etpName}}</view>
						</view>
					</view>
				</view>
			</view>
			<view class="body">
				<view class="list radius">
					<view class="item" @click="navigatorTo('car')">
						<view class="flex">
							<view class="icon car"></view>
							<view>车辆管理</view>
						</view>
						<u-icon name="arrow-right" size="16"></u-icon>
					</view>
					<view class="item" @click="navigatorTo('driver')">
						<view class="flex">
							<view class="icon driver"></view>
							<view>司机管理</view>
						</view>
						<u-icon name="arrow-right" size="16"></u-icon>
					</view>
					<view class="item" @click="navigatorTo('code')">
						<view class="flex">
							<view class="icon code"></view>
							<view>二维码管理</view>
						</view>
						<u-icon name="arrow-right" size="16"></u-icon>
					</view>
				</view>
				<view class="list">
					<!-- <view class="item" @click="">
						<view class="flex">
							<view class="icon about"></view>
							<view>关于我们</view>
						</view>
						<u-icon name="arrow-right" size="16"></u-icon>
					</view> -->
					<view class="item" @click="navigatorTo('set')">
						<view class="flex">
							<view class="icon set"></view>
							<view>设置</view>
						</view>
						<u-icon name="arrow-right" size="16"></u-icon>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>
	import Cache from '@/utils/cache'
	export default {
		data() {
			return {
				src: 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg',
				userInfo: {},
				menu: Cache.get('MENU')
			}
		},
		created() {
			this.userInfo = Cache.get("USERINFO")[0];
			console.log(this.userInfo)
		},
		methods: {
			navigatorTo(str) {
				if (str == 'car') {
					if (this.menu.vehicleList == 0 && this.menu.vehicleReviewlist == 0) {
						uni.$u.toast('您当前没有车辆管理权限，请联系管理员开通！')
						return
					}
					uni.navigateTo({
						url: "/pages/vehicle/index"
					})
				}
				if (str == 'driver') {
					if (this.menu.driverList == 0 && this.menu.driverReviewList == 0) {
						uni.$u.toast('您当前没有司机管理权限，请联系管理员开通！')
						return
					}
					uni.navigateTo({
						url: "/pages/driver/index"
					})
				}
				if (str == 'code') {
					uni.navigateTo({
						url: "/pages/user/QRcode"
					})
				}
				if (str == 'set') {
					uni.navigateTo({
						url: "/pages/user/set"
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user-wrap {
		width: 100vw;
		height: 100vh;
		background: #FAFAFA;

		.bg-user {
			width: 100vw;
			position: absolute;
			top: 0;
			left: 0;
		}
	}

	.user-content {
		position: absolute;
		top: 120rpx;
		width: 100vw;
		box-sizing: border-box;

		.header {
			padding: 0 48rpx;
		}

		.set {
			display: flex;
			align-items: center;
			justify-content: flex-end;
		}

		.info-wrap {
			display: flex;
			align-items: center;
			padding-top: 12rpx;
			.avatar{
				width: 108rpx;
				height: 110rpx;
				border-radius: 50%;
			}

			.info {
				flex: 1;
				margin-left: 24rpx;

				.name {
					font-size: 38rpx;
					font-weight: 500;
					color: #333333;
					line-height: 50rpx;
					margin-bottom: 8rpx;
				}

				.company {
					display: flex;
					align-items: center;
					font-size: 24rpx;
					font-weight: 500;
					color: #333333;
					line-height: 36rpx;

					.icon {
						width: 44rpx;
						height: 44rpx;
						margin-right: 16rpx;
					}

					view {
						flex: 1;
					}
				}
			}
		}

		.body {
			.radius {
				margin-top: 48rpx;
				border-radius: 48rpx 48rpx 0 0;
			}

			.list {
				margin-bottom: 24rpx;
				background: #fff;
				padding: 18rpx 48rpx;

				.item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 30rpx;
					font-weight: 500;
					color: #333333;
					padding: 22rpx 0;
					border-bottom: 1rpx solid #F5F7FB;

					.gray {
						font-size: 30rpx;
						font-weight: 400;
						color: #9E9E9E;
					}

					.flex {
						display: flex;
						align-items: center;
					}

					.icon {
						width: 48rpx;
						height: 48rpx;
						margin-right: 12rpx;
						background-position: center;
						background-size: contain;
						background-repeat: no-repeat;

						&.car {
							background-image: url('@/static/icon_car.png');
						}

						&.driver {
							background-image: url('@/static/icon_driver.png');
						}

						&.code {
							background-image: url('@/static/icon_code.png');
						}

						&.about {
							background-image: url('@/static/icon_aboutus.png');
						}

						&.set {
							background-image: url('@/static/icon_set.png');
						}
					}

					&:last-child {
						border-bottom: none;
					}
				}
			}
		}
	}
</style>
